deferred class CD_CANVAS_CONTROL

inherit
	CANVAS_DRAW

feature {ANY}

	clear
		-- Cleans the active canvas using the current background color. This 
		-- action is interpreted very differently by each driver. Many drivers 
		-- simply draw a rectangle with the current background color. It is NOT 
		-- necessary to call "clear" when the canvas has just been created, as at 
		-- this moment it is already clean. Most file-based drivers do not 
		-- implement this function.
		do
			int_canvas_clear (cnvs);
		end

	flush
		-- Has a different meaning for each driver. It is useful to send 
		-- information to buffered devices and to move to a new page or layer. In 
		-- all cases, the current canvas attributes are preserved.
		do
			int_canvas_flush (cnvs);
		end

	save_state: POINTER
		-- Saves the state of attributes of the active canvas. It does not save 
		-- play callbacks, polygon creation states (begin/vertex/vertex/...), the 
		-- palette,	complex clipping regions and driver internal attributes.
		do
			Result := int_canvas_save_state (cnvs);
		end

	restore_state (state: POINTER)
		-- Restores the attribute state of the active canvas. It can be used 
		-- between canvases of different contexts. It can be used several times 
		-- for the same state. 
		do
			int_canvas_restore_state (cnvs, state);
		end

	release_state (state: POINTER)
		-- Releases the memory allocated by the "save_state" function.
		do
			int_canvas_release_state (state);
		end

feature {NONE}

	-- Internals

	int_canvas_clear (data: POINTER)
		external
			"C inline use %"eiffel-iup.h%""
      alias
			"cdCanvasClear ($data);"
      end

	int_canvas_flush (data: POINTER)
		external
			"C inline use %"eiffel-iup.h%""
      alias
			"cdCanvasFlush ($data);"
      end

	int_canvas_save_state (data: POINTER): POINTER
		external
			"C inline use %"eiffel-iup.h%""
      alias
			"return cdCanvasSaveState ($data);"
      end

	int_canvas_restore_state (data, state: POINTER)
		external
			"C inline use %"eiffel-iup.h%""
      alias
			"cdCanvasRestoreState ($data, $state);"
      end

	int_canvas_release_state (state: POINTER)
		external
			"C inline use %"eiffel-iup.h%""
      alias
			"cdReleaseState ($state);"
      end

end

-- The MIT License (MIT)

-- Copyright (c) 2016,2019 by German A. Arias

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in 
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
